/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.lance.testing.time.impl;

import com.lance.testing.time.Time;

/**
 *
 * @author Lance
 */
public class TimeImpl implements Time
{

    private int hour;
    private int min;
    private int sec;

    public TimeImpl(int hour, int min, int sec)
    {
        this.hour = hour;
        this.min = min;
        this.sec = sec;
    }

    @Override
    public void incrementSeconds()
    {
        sec++;

        if (sec > 59)
        {
            sec = 0;
            incrementMinutes();
        }
    }

    @Override
    public void incrementMinutes()
    {
        min++;
        if (min > 59)
        {
            min = 0;
            incrementHours();
        }
    }

    @Override
    public void incrementHours()
    {
        hour++;
        if (hour > 23)
        {
            hour = 0;
        }
    }

    @Override
    public void printTime()
    {
        if (hour < 10)
        {
            System.out.println("0");
        }
        System.out.println(hour + ":");

        if (min < 10)
        {
            System.out.println("0");
        }
        System.out.println(min + ":");

        if (sec < 10)
        {
            System.out.println("0");
        }
        System.out.println(sec);
    }

    @Override
    public int getHour()
    {
        return hour;
    }

    @Override
    public int getMin()
    {
        return min;
    }

    @Override
    public int getSec()
    {
        return sec;
    }

    @Override
    public boolean equalTime(Time otherClock)
    {
        return (hour == otherClock.getHour() 
		    && min == otherClock.getMin() 
		    && sec == otherClock.getSec());
    }
}
